package com.wanxi;

import java.util.ArrayList;

public class Follow {
    private ArrayList followList = new ArrayList<>();


    public ArrayList getFollowList() {
        return followList;
    }

    public void setFollowList(ArrayList followList) {
        this.followList = followList;
    }

    /**
     * 关注别人的账号。
     *
     * @param account
     * @return
     */
    public Boolean followAccount(String account) {
        followList.add(account);
        return true;
    }

    /**
     * 返回一个共同关注的集合。
     *
     * @param other
     */
    public ArrayList commonFollowList(Follow other) {
        ArrayList commonArrayList = new ArrayList<>();
        commonArrayList.addAll(getFollowList());
        commonArrayList.retainAll(other.getFollowList());
        return commonArrayList;
    }

    /**
     * 返回一个独自关注的集合
     */
    public ArrayList aloneFollowList(Follow other) {
        ArrayList aloneFollowList = new ArrayList<>();
        aloneFollowList.addAll(getFollowList());
        aloneFollowList.removeAll(other.getFollowList());
        return aloneFollowList;
    }

    /**
     * 返回两个用户所有的关注列表，不重复。
     */
    public ArrayList allFollowList(Follow other) {

        ArrayList aloneFollowList = new ArrayList<>();
        aloneFollowList.addAll(getFollowList());
        aloneFollowList.removeAll(other.getFollowList());

        ArrayList allArrayList = new ArrayList<>();

        allArrayList.addAll(aloneFollowList);
        allArrayList.addAll(other.getFollowList());

        return allArrayList;
    }


}
